<!DOCTYPE html>
<html>
<body>


<!-- 多选权限树 -->
<div th:fragment="roleTreePanel">
	<div id="menuContent" class="menuContent" style="display:none; position: absolute;">
		<ul id="roleTree" class="ztree" style="margin-top:0; width:500px; height: 300px;"></ul>
	</div>
</div>
<script th:fragment="roleTreeJs" type="text/javascript">
	var setting = {
		check: {
			enable: true,
			//chkboxType: { "Y" : "s", "N" : "s" }
		},
		view: {
			//dblClickExpand: true
		},
		data: {
			simpleData: {
				enable: true
			}
		},
		callback: {
			beforeClick: beforeClick,
			onCheck: onCheck
		}
	};

	function beforeClick(treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj("roleTree");
		zTree.checkNode(treeNode, !treeNode.checked, null, true);
		return false;
	}
	// 选中赋值
	function onCheck(e, treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj("roleTree");
		var nodes = zTree.getCheckedNodes(true);
		var names = "";
		var ids = "";
		var namesList = [];
		for (var i=0, l=nodes.length; i<l; i++) {
			if(nodes[i].getCheckStatus().half) {
				continue;
			}

			names += nodes[i].name + ",";
			ids += nodes[i].id + ",";
			namesList.push(nodes[i].name);
		}
		if (names.length > 0 ) {
			names = names.substring(0, names.length-1);
		}
		if (ids.length > 0 ) {
			ids = ids.substring(0, ids.length-1);
		}

		var optHtml = "";
		for(var i = 0; i < namesList.length; i++) {
			optHtml += "<option>"+namesList[i]+"</option>";
		}
		$("#roleNames").html(optHtml);

	//	$("#roleNames").val(names);
		$("#roleIds").val(ids);

	}

	function showMenu() {
		var cityObj = $("#roleNames");
		var cityOffset = $("#roleNames").offset();
		$("#menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");

		var zTreeObj = $.fn.zTree.getZTreeObj("roleTree");
		zTreeObj.expandAll(true);
		zTreeObj.checkAllNodes(false);

		if ($("#roleIds").val() != "") {
			var roleIds = $("#roleIds").val().split(",");
			for(var i = 0; i < roleIds.length; i++) {
				var node = zTreeObj.getNodeByParam("id", roleIds[i], null);
				if(node != null) {
					zTreeObj.checkNode(node, true, true);
				}
			}
		}

		$("body").bind("mousedown", onBodyDown);
	}
	function hideMenu() {
		$("#menuContent").fadeOut("fast");
		$("body").unbind("mousedown", onBodyDown);
	}
	function onBodyDown(event) {
		if (!(event.target.id == "menuBtn" || event.target.id == "roleNames" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
			hideMenu();
		}
	}

	$(document).ready(function(){
		$.ajax({
			type : "GET",
			url : '/security/role/queryTree',
			beforeSend : function() {
			},
			complete : function() {
			},
			error : function(request) {
				layer.alert("系统错误");
			},
			success : function(result) {
				if (result.status == 0) {
					var data = result.data;
					$.fn.zTree.init($("#roleTree"), setting, data);
				} else {
					layer.alert(result.message);
				}
			}
		});

	});
</script>


<!-- 多选用户数树 -->
<div th:fragment="multuserTreePanel">
	<div id="multusermenuContent" class="multusermenuContent" style="display:none; position: absolute;">
		<ul id="multuserTree" class="ztree" style="margin-top:0; width:500px; height: 300px;"></ul>
	</div>
</div>
<script th:fragment="multuserTreeJs" type="text/javascript">
	var setting = {
		check: {
			enable: true,
			//chkboxType: { "Y" : "s", "N" : "s" }
		},
		view: {
			//dblClickExpand: true
		},
		data: {
			simpleData: {
				enable: true
			}
		},
		callback: {
			beforeClick: beforeClick,
			onCheck: onCheck
		}
	};

	function beforeClick(treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj("multuserTree");
		zTree.checkNode(treeNode, !treeNode.checked, null, true);
		return false;
	}
	// 选中赋值
	function onCheck(e, treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj("multuserTree");
		var nodes = zTree.getCheckedNodes(true);
		var names = "";
		var ids = "";
		var namesList = [];
		for (var i=0, l=nodes.length; i<l; i++) {
			if(nodes[i].getCheckStatus().half) {
				continue;
			}

			names += nodes[i].name + ",";
			ids += nodes[i].id + ",";
			namesList.push(nodes[i].name);
		}
		if (names.length > 0 ) {
			names = names.substring(0, names.length-1);
		}
		if (ids.length > 0 ) {
			ids = ids.substring(0, ids.length-1);
		}

		var optHtml = "";
		for(var i = 0; i < namesList.length; i++) {
			optHtml += "<option>"+namesList[i]+"</option>";
		}
		$("#multuserNames").html(optHtml);

	//	$("#roleNames").val(names);
		$("#multuserIds").val(ids);

	}

	function showMenu() {
		var cityObj = $("#multuserNames");
		var cityOffset = $("#multuserNames").offset();
		$("#multusermenuContent").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");

		var zTreeObj = $.fn.zTree.getZTreeObj("multuserTree");
		zTreeObj.expandAll(true);
		zTreeObj.checkAllNodes(false);

		if ($("#multuserIds").val() != "") {
			var roleIds = $("#multuserIds").val().split(",");
			for(var i = 0; i < roleIds.length; i++) {
				var node = zTreeObj.getNodeByParam("id", roleIds[i], null);
				if(node != null) {
					zTreeObj.checkNode(node, true, true);
				}
			}
		}

		$("body").bind("mousedown", onBodyDown);
	}
	function hideMenu() {
		$("#multusermenuContent").fadeOut("fast");
		$("body").unbind("mousedown", onBodyDown);
	}
	function onBodyDown(event) {
		if (!(event.target.id == "menuBtn" || event.target.id == "multuserNames" || event.target.id == "multusermenuContent" || $(event.target).parents("#multusermenuContent").length>0)) {
			hideMenu();
		}
	}

	$(document).ready(function(){
		$.ajax({
			type : "GET",
			url : '/security/user/queryTree',
			data : {
				search_EQ_type:"1"
			},
			beforeSend : function() {
			},
			complete : function() {
			},
			error : function(request) {
				layer.alert("系统错误");
			},
			success : function(result) {
				if (result.status == 0) {
					var data = result.data;
					$.fn.zTree.init($("#multuserTree"), setting, data);
				} else {
					layer.alert(result.message);
				}
			}
		});

	});
</script>


<!-- 单选权限树 -->
<div th:fragment="singleSelectRoleTreePanel">
	<div id="menuContent" class="menuContent" style="display:none; position: absolute;">
		<ul id="roleTree" class="ztree" style="margin-top:0; width:500px; height: 300px;"></ul>
	</div>
</div>
<script th:fragment="singleSelectRoleTreeJs" type="text/javascript">
	var setting = {
		check: {
			enable: true,
			chkStyle: "radio",
			radioType: "all"
		},
		data: {
			simpleData: {
				enable: true
			}
		},
		callback: {
	//		beforeClick: beforeClick,
			onClick: beforeClick,
			onCheck: onCheck
		}
	};

	function beforeClick(treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj("roleTree");
		zTree.checkNode(treeNode, !treeNode.checked, null, true);
		return false;
	}
	// 选中赋值
	function onCheck(e, treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj("roleTree");
		var nodes = zTree.getCheckedNodes(true);
		var names = "";
		var ids = "";
		for (var i=0, l=nodes.length; i<l; i++) {
			if(nodes[i].getCheckStatus().half) {
				continue;
			}

			names += nodes[i].name + ",";
			ids += nodes[i].id + ",";
		}
		if (names.length > 0 ) {
			names = names.substring(0, names.length-1);
		}
		if (ids.length > 0 ) {
			ids = ids.substring(0, ids.length-1);
		}

		$("#parentName").val(names);
		$("#parentId").val(ids);
		hideMenu();
	}

	function showMenu() {
		var cityObj = $("#parentName");
		var cityOffset = $("#parentName").offset();
		$("#menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");

		var zTreeObj = $.fn.zTree.getZTreeObj("roleTree");
		zTreeObj.expandAll(true);
		zTreeObj.checkAllNodes(false);

		$("body").bind("mousedown", onBodyDown);
	}
	function hideMenu() {
		$("#menuContent").fadeOut("fast");
		$("body").unbind("mousedown", onBodyDown);
	}
	function onBodyDown(event) {
		if (!(event.target.id == "menuBtn" || event.target.id == "parentName" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
			hideMenu();
		}
	}
	function refreshTree() {
		var zTreeObj = $.fn.zTree.getZTreeObj("roleTree");
		zTreeObj.refresh();
	}
	$(document).ready(function(){
		$.ajax({
			type : "GET",
			url : '/security/role/queryTree',
			beforeSend : function() {
			},
			complete : function() {
			},
			error : function(request) {
				layer.alert("系统错误");
			},
			success : function(result) {
				if (result.status == 0) {
					var data = result.data;
					$.fn.zTree.init($("#roleTree"), setting, data);
				} else {
					layer.alert(result.message);
				}
			}
		});

	});
</script>

<!-- 多选数据权限 -->
<div th:fragment="dataPermissionTreePanel">
	<div id="dataPermission-menuContent" class="menuContent" style="display:none; position: absolute;">
		<ul id="shopTree" class="ztree" style="margin-top:0; width:400px; height: 300px;"></ul>
	</div>
</div>
<script th:fragment="dataPermissionTreeJs" type="text/javascript">

	function showMenu_DataPermission() {
		var zTreeObj = $.fn.zTree.getZTreeObj("shopTree");
		zTreeObj.expandAll(true);
		zTreeObj.checkAllNodes(false);

		var roleIds = $("#shopCode").find("option");
		for(var i = 0; i < roleIds.length; i++) {
			var node = zTreeObj.getNodeByParam("origId", $(roleIds[i]).prop("value"), null);
			if(node != null) {
				zTreeObj.checkNode(node, true, true);
			}
		}

		var cityObj = $("#shopCode");
		var cityOffset = $("#shopCode").offset();
		$("#dataPermission-menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + "px"}).slideDown("fast");

		function dataPermissionTreeOnMousedown(event) {
			if (!(event.target.id == "menuBtn" || event.target.id == "shopCode" || event.target.id == "dataPermission-menuContent" || $(event.target).parents("#dataPermission-menuContent").length>0)) {
				$("#dataPermission-menuContent").fadeOut("fast");
				$("body").unbind("mousedown", dataPermissionTreeOnMousedown);
			}
		}

		$("body").bind("mousedown", dataPermissionTreeOnMousedown);
	}

	$(document).ready(function(){
		var dataPermissionTree = {
			check: {
				enable: true
			},
			view: {

			},
			data: {
				simpleData: {
					enable: true
				}
			},
			callback: {
				beforeClick: function(treeId, treeNode) {
					var zTree = $.fn.zTree.getZTreeObj("shopTree");
					zTree.checkNode(treeNode, !treeNode.checked, null, true);
					return false;
				},
				onCheck: function(e, treeId, treeNode) {
					var zTree = $.fn.zTree.getZTreeObj("shopTree");
					var nodes = zTree.getCheckedNodes(true);

					var namesList = [];
					var idsList=[];
					for (var i=0, l=nodes.length; i<l; i++) {
						if(nodes[i].getCheckStatus().half) {
							continue;
						}
						idsList.push(nodes[i].id);
						namesList.push(nodes[i].name);
					}

					var optHtml = "";
					for(var i = 0; i < namesList.length; i++) {
						optHtml += "<option value='"+idsList[i]+"'>"+namesList[i]+"</option>";
					}
					$("#shopCode").html(optHtml);
					//$("#shopCode").val(shopCodes);
				}
			}
		};
		$.ajax({
			type : "GET",
			url : '/manager/bank/queryTree',
			beforeSend : function() {
			},
			complete : function() {
			},
			error : function(request) {
				layer.alert("系统错误");
			},
			success : function(result) {
				if (result.status == 0) {
					var data = result.data;
					$.fn.zTree.init($("#shopTree"), dataPermissionTree, data);
				} else {
					layer.alert(result.message);
				}
			}
		});

	});
</script>

<!-- 单选分配人员树 -->
<div th:fragment="userTreePanel">
	<div id="menuContent" class="menuContent" style="display:none; position: absolute;">
		<ul id="userTree" class="ztree" style="margin-top:0; width:500px; height: 300px;"></ul>
	</div>
</div>
<script th:fragment="userTreeJs" type="text/javascript">
	var setting = {
		check: {
			enable: true,
			chkStyle: "radio",
			radioType: "all"
		},
		data: {
			simpleData: {
				enable: true
			}
		},
		callback: {
	//		beforeClick: beforeClick,
			onClick: beforeClick,
			onCheck: onCheck
		}
	};

	function beforeClick(treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj("userTree");
		zTree.checkNode(treeNode, !treeNode.checked, null, true);
		return false;
	}
	// 选中赋值
	function onCheck(e, treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj("userTree");
		var nodes = zTree.getCheckedNodes(true);
		var names = "";
		var ids = "";
		for (var i=0, l=nodes.length; i<l; i++) {
			if(nodes[i].getCheckStatus().half) {
				continue;
			}

			names += nodes[i].name + ",";
			ids += nodes[i].id + ",";
		}
		if (names.length > 0 ) {
			names = names.substring(0, names.length-1);
		}
		if (ids.length > 0 ) {
			ids = ids.substring(0, ids.length-1);
		}

		$("#userName").val(names);
		$("#operator").val(ids);
		hideMenu();
	}

	function showMenu() {
		var cityObj = $("#userName");
		var cityOffset = $("#userName").offset();
		$("#menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");

		var zTreeObj = $.fn.zTree.getZTreeObj("userTree");
		zTreeObj.expandAll(true);
		zTreeObj.checkAllNodes(false);

		$("body").bind("mousedown", onBodyDown);
	}
	function hideMenu() {
		$("#menuContent").fadeOut("fast");
		$("body").unbind("mousedown", onBodyDown);
	}
	function onBodyDown(event) {
		if (!(event.target.id == "menuBtn" || event.target.id == "userName" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
			hideMenu();
		}
	}
	function refreshTree() {
		var zTreeObj = $.fn.zTree.getZTreeObj("userTree");
		zTreeObj.refresh();
	}
	$(document).ready(function(){
		$.ajax({
			type : "GET",
			url : '/security/user/queryTree',
			data : {
						search_EQ_city:getQueryString("city")
					},
			beforeSend : function() {
			},
			complete : function() {
			},
			error : function(request) {
				layer.alert("系统错误");
			},
			success : function(result) {
				if (result.status == 0) {
					var data = result.data;
					$.fn.zTree.init($("#userTree"), setting, data);
				} else {
					layer.alert(result.message);
				}
			}
		});

	});
</script>

<!-- 单选商品分类树 -->
<div th:fragment="shopclassifySingleTreePanel">
	<div id="menuContent" class="menuContent" style="display:none; position: absolute;">
		<ul id="shopclassifyTree" class="ztree" style="margin-top:0; width:500px; height: 300px;"></ul>
	</div>
</div>
<script th:fragment="shopclassifySingleTreeJs" type="text/javascript">
	var setting = {
		check: {
			enable: true,
			chkStyle: "radio",
			radioType: "all"
		},
		data: {
			simpleData: {
				enable: true
			}
		},
		callback: {
	//		beforeClick: beforeClick,
			onClick: beforeClick,
			onCheck: onCheck
		}
	};

	function beforeClick(treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj("shopclassifyTree");
		zTree.checkNode(treeNode, !treeNode.checked, null, true);
		return false;
	}
	// 选中赋值
	function onCheck(e, treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj("shopclassifyTree");
		var nodes = zTree.getCheckedNodes(true);
		var names = "";
		var ids = "";
		for (var i=0, l=nodes.length; i<l; i++) {
			if(nodes[i].getCheckStatus().half) {
				continue;
			}

			names += nodes[i].name + ",";
			ids += nodes[i].id + ",";
		}
		if (names.length > 0 ) {
			names = names.substring(0, names.length-1);
		}
		if (ids.length > 0 ) {
			ids = ids.substring(0, ids.length-1);
		}

		$("#shopclassifyName").val(names);
		$("#shopclassifyId").val(ids);
		hideMenu();
	}

	function showMenu() {
		var cityObj = $("#shopclassifyName");
		var cityOffset = $("#shopclassifyName").offset();
		$("#menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");

		var zTreeObj = $.fn.zTree.getZTreeObj("shopclassifyTree");
		zTreeObj.expandAll(true);
		zTreeObj.checkAllNodes(false);

		$("body").bind("mousedown", onBodyDown);
	}
	function hideMenu() {
		$("#menuContent").fadeOut("fast");
		$("body").unbind("mousedown", onBodyDown);
	}
	function onBodyDown(event) {
		if (!(event.target.id == "menuBtn" || event.target.id == "shopclassifyName" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
			hideMenu();
		}
	}
	function refreshTree() {
		var zTreeObj = $.fn.zTree.getZTreeObj("shopclassifyTree");
		zTreeObj.refresh();
	}
	$(document).ready(function(){
		var levelId= getQueryString("levelId");
		$.ajax({
			type : "GET",
			url : '/manager/classify/queryTree',
			data : {
						search_EQ_levelId:levelId
					},
			beforeSend : function() {
			},
			complete : function() {
			},
			error : function(request) {
				layer.alert("系统错误");
			},
			success : function(result) {
				if (result.status == 0) {
					var data = result.data;
					$.fn.zTree.init($("#shopclassifyTree"), setting, data);
				} else {
					layer.alert(result.message);
				}
			}
		});

	});
</script>

<!-- 多选商品分类树 -->
<div th:fragment="shopclassifyTreePanel">
	<div id="shopclassify-menuContent" class="menuContent" style="display:none; position: absolute;">
		<ul id="shopclassifyTree" class="ztree" style="margin-top:0; width:400px; height: 300px;"></ul>
	</div>
</div>
<script th:fragment="shopclassifyTreeJs" type="text/javascript">

	function showMenu() {
		var zTreeObj = $.fn.zTree.getZTreeObj("shopclassifyTree");
		zTreeObj.expandAll(true);
		zTreeObj.checkAllNodes(false);

		/* var roleIds = $("#shopclassifyName").find("option");
		for(var i = 0; i < roleIds.length; i++) {
			var node = zTreeObj.getNodeByParam("id", $(roleIds[i]).prop("value"), null);
			if(node != null) {
				zTreeObj.checkNode(node, true, true);
			}
		} */

		if ($("#shopclassifyIds").val() != "") {
			var roleIds = $("#shopclassifyIds").val().split(",");
			for(var i = 0; i < roleIds.length; i++) {
				var node = zTreeObj.getNodeByParam("id", roleIds[i], null);
				if(node != null) {
					zTreeObj.checkNode(node, true, true);
				}
			}
		}

		var cityObj = $("#shopclassifyName");
		var cityOffset = $("#shopclassifyName").offset();
		$("#shopclassify-menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + "px"}).slideDown("fast");

		function dataPermissionTreeOnMousedown(event) {
			if (!(event.target.id == "menuBtn" || event.target.id == "shopclassifyName" || event.target.id == "shopclassify-menuContent" || $(event.target).parents("#shopclassify-menuContent").length>0)) {
				$("#shopclassify-menuContent").fadeOut("fast");
				$("body").unbind("mousedown", dataPermissionTreeOnMousedown);
			}
		}

		$("body").bind("mousedown", dataPermissionTreeOnMousedown);
	}

	$(document).ready(function(){
		var dataPermissionTree = {
			check: {
				enable: true
			},
			view: {

			},
			data: {
				simpleData: {
					enable: true
				}
			},
			callback: {
				beforeClick: function(treeId, treeNode) {
					var zTree = $.fn.zTree.getZTreeObj("shopclassifyTree");
					zTree.checkNode(treeNode, !treeNode.checked, null, true);
					return false;
				},
				onCheck: function(e, treeId, treeNode) {
					var zTree = $.fn.zTree.getZTreeObj("shopclassifyTree");
					var nodes = zTree.getCheckedNodes(true);
					var ids = "";
					var namesList = [];
					var idsList=[];
					for (var i=0, l=nodes.length; i<l; i++) {
						if(nodes[i].getCheckStatus().half) {
							continue;
						}
						idsList.push(nodes[i].id);
						namesList.push(nodes[i].name);
						ids += nodes[i].id + ",";
					}
					var optHtml = "";
					for(var i = 0; i < namesList.length; i++) {
						optHtml += "<option>"+namesList[i]+"</option>";
					}
					if (ids.length > 0 ) {
						ids = ids.substring(0, ids.length-1);
					}
					$("#shopclassifyName").html(optHtml);
					$("#shopclassifyIds").val(ids);
				}
			}
		};
		var levelId= getQueryString("levelId");
		$.ajax({
			type : "GET",
			url : '/manager/classify/queryTree',
			data : {
						search_EQ_levelId:levelId
					},
			beforeSend : function() {
			},
			complete : function() {
			},
			error : function(request) {
				layer.alert("系统错误");
			},
			success : function(result) {
				if (result.status == 0) {
					var data = result.data;
					$.fn.zTree.init($("#shopclassifyTree"), dataPermissionTree, data);
				} else {
					layer.alert(result.message);
				}
			}
		});

	});
</script>

<!-- 单选城市树 -->
<div th:fragment="singleSelectCityTreePanel">
	<div id="menuContent" class="menuContent" style="display:none; position: absolute;">
		<ul id="cityTree" class="ztree" style="margin-top:0; width:500px; height: 300px;"></ul>
	</div>
</div>
<script th:fragment="singleSelectCityTreeJs" type="text/javascript">
	var setting = {
		check: {
			enable: true,
			chkStyle: "radio",
			radioType: "all"
		},
		data: {
			simpleData: {
				enable: true
			}
		},
		callback: {
	//		beforeClick: beforeClick,
			onClick: beforeClick,
			onCheck: onCheck
		}
	};

	function beforeClick(treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj("cityTree");
		zTree.checkNode(treeNode, !treeNode.checked, null, true);
		return false;
	}
	// 选中赋值
	function onCheck(e, treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj("cityTree");
		var nodes = zTree.getCheckedNodes(true);
		var names = "";
		var ids = "";
		var citys="";
		for (var i=0, l=nodes.length; i<l; i++) {
			if(nodes[i].getCheckStatus().half) {
				continue;
			}

			names += nodes[i].name + ",";
			ids += nodes[i].id + ",";
			citys += nodes[i].city + ",";
		}
		if (names.length > 0 ) {
			names = names.substring(0, names.length-1);
		}
		if (ids.length > 0 ) {
			ids = ids.substring(0, ids.length-1);
		}
		if (citys.length > 0 ) {
			citys = citys.substring(0, citys.length-1);
		}

		$("#parentName").val(names);
		$("#city").val(citys);
		$("#bankId").val(ids);
		hideMenu();
	}

	function showMenu() {
		var cityObj = $("#parentName");
		var cityOffset = $("#parentName").offset();
		$("#menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");

		var zTreeObj = $.fn.zTree.getZTreeObj("cityTree");
		zTreeObj.expandAll(true);
		zTreeObj.checkAllNodes(false);

		$("body").bind("mousedown", onBodyDown);
	}
	function hideMenu() {
		$("#menuContent").fadeOut("fast");
		$("body").unbind("mousedown", onBodyDown);
	}
	function onBodyDown(event) {
		if (!(event.target.id == "menuBtn" || event.target.id == "parentName" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
			hideMenu();
		}
	}
	function refreshTree() {
		var zTreeObj = $.fn.zTree.getZTreeObj("cityTree");
		zTreeObj.refresh();
	}
	$(document).ready(function(){
		$.ajax({
			type : "GET",
			url : '/manager/bank/queryTree',
			beforeSend : function() {
			},
			complete : function() {
			},
			error : function(request) {
				layer.alert("系统错误");
			},
			success : function(result) {
				if (result.status == 0) {
					var data = result.data;
					$.fn.zTree.init($("#cityTree"), setting, data);
				} else {
					layer.alert(result.message);
				}
			}
		});

	});
</script>

<!-- 多选客户权限 -->
<div th:fragment="dataUserTreePanel">
	<div id="dataUser-menuContent" class="menuContent" style="display:none; position: absolute;">
		<ul id="userTree" class="ztree" style="margin-top:0; width:400px; height: 300px;"></ul>
	</div>
</div>
<script th:fragment="dataUserTreeJs" type="text/javascript">

function showMenu_DataPermission() {
	var zTreeObj = $.fn.zTree.getZTreeObj("userTree");
	zTreeObj.expandAll(true);
	zTreeObj.checkAllNodes(false);

	var roleIds = $("#userCode").find("option");
	for(var i = 0; i < roleIds.length; i++) {
		var node = zTreeObj.getNodeByParam("origId", $(roleIds[i]).prop("value"), null);
		if(node != null) {
			zTreeObj.checkNode(node, true, true);
		}
	}

	var cityObj = $("#userCode");
	var cityOffset = $("#userCode").offset();
	$("#dataUser-menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + "px"}).slideDown("fast");

	function dataPermissionTreeOnMousedown(event) {
		if (!(event.target.id == "menuBtn" || event.target.id == "userCode" || event.target.id == "dataUser-menuContent" || $(event.target).parents("#dataUser-menuContent").length>0)) {
			$("#dataUser-menuContent").fadeOut("fast");
			$("body").unbind("mousedown", dataPermissionTreeOnMousedown);
		}
	}

	$("body").bind("mousedown", dataPermissionTreeOnMousedown);
}

$(document).ready(function(){
	var dataPermissionTree = {
		check: {
			enable: true
		},
		view: {

		},
		data: {
			simpleData: {
				enable: true
			}
		},
		callback: {
			beforeClick: function(treeId, treeNode) {
				var zTree = $.fn.zTree.getZTreeObj("userTree");
				zTree.checkNode(treeNode, !treeNode.checked, null, true);
				return false;
			},
			onCheck: function(e, treeId, treeNode) {
				var zTree = $.fn.zTree.getZTreeObj("userTree");
				var nodes = zTree.getCheckedNodes(true);

				var namesList = [];
				var idsList=[];
				for (var i=0, l=nodes.length; i<l; i++) {
					if(nodes[i].getCheckStatus().half) {
						continue;
					}
					idsList.push(nodes[i].id);
					namesList.push(nodes[i].name);
				}

				var optHtml = "";
				for(var i = 0; i < namesList.length; i++) {
					optHtml += "<option value='"+idsList[i]+"'>"+namesList[i]+"</option>";
				}
				$("#userCode").html(optHtml);
				//$("#shopCode").val(shopCodes);
			}
		}
	};
	$.ajax({
		type : "GET",
		url : '/manager/usermanager/queryTree',
		beforeSend : function() {
		},
		complete : function() {
		},
		error : function(request) {
			layer.alert("系统错误");
		},
		success : function(result) {
			if (result.status == 0) {
				var data = result.data;
				$.fn.zTree.init($("#userTree"), dataPermissionTree, data);
			} else {
				layer.alert(result.message);
			}
		}
	});

});
</script>
</body>
</html>